package com.farm.resume.service.impl;

import com.farm.core.auth.domain.LoginUser;
import com.farm.core.sql.query.DataQuery;
import com.farm.core.time.TimeTool;
import com.farm.resume.dao.ResumeintensionDaoInter;
import com.farm.resume.domain.Resumeintension;
import com.farm.resume.service.ResumeintensionServiceInter;
import javax.annotation.Resource;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;












@Service
public class ResumeintensionServiceImpl
  implements ResumeintensionServiceInter
{
  @Resource
  private ResumeintensionDaoInter resumeintensionDaoImpl;
  private static final Logger log = Logger.getLogger(ResumeintensionServiceImpl.class);
  
  @Transactional
  public Resumeintension insertResumeintensionEntity(Resumeintension entity, LoginUser user)
  {
    entity.setCuser(user.getId());
    entity.setCtime(TimeTool.getTimeDate14());
    entity.setCusername(user.getName());
    entity.setEuser(user.getId());
    entity.setEusername(user.getName());
    entity.setEtime(TimeTool.getTimeDate14());
    entity.setPstate("1");
    return this.resumeintensionDaoImpl.insertEntity(entity);
  }
  
  @Transactional
  public Resumeintension editResumeintensionEntity(Resumeintension entity, LoginUser user)
  {
    Resumeintension entity2 = this.resumeintensionDaoImpl.getEntity(entity.getId());
    entity2.setEuser(user.getId());
    entity2.setEusername(user.getName());
    entity2.setEtime(TimeTool.getTimeDate14());
    entity2.setWorkstat(entity.getWorkstat());
    entity2.setWorkpay(entity.getWorkpay());
    entity2.setWorkindustry(entity.getWorkindustry());
    entity2.setWorkaddr(entity.getWorkaddr());
    entity2.setWorkoccupation(entity.getWorkoccupation());
    entity2.setWorkaddrarea(entity.getWorkaddrarea());
    entity2.setWorknature(entity.getWorknature());
    entity2.setUserid(entity.getUserid());
    entity2.setPcontent(entity.getPcontent());
    this.resumeintensionDaoImpl.editEntity(entity2);
    return entity2;
  }
  

  @Transactional
  public void deleteResumeintensionEntity(String id, LoginUser user)
  {
    this.resumeintensionDaoImpl.deleteEntity(this.resumeintensionDaoImpl.getEntity(id));
  }
  

  @Transactional
  public Resumeintension getResumeintensionEntity(String id)
  {
    if (id == null) {
      return null;
    }
    return this.resumeintensionDaoImpl.getEntity(id);
  }
  

  @Transactional
  public DataQuery createResumeintensionSimpleQuery(DataQuery query)
  {
    DataQuery dbQuery = DataQuery.init(query, "FARM_RESUME_INTENSION", 
      "ID,WORKSTAT,WORKPAY,WORKINDUSTRY,WORKADDR,WORKOCCUPATION,WORKADDRAREA,WORKNATURE,USERID,PCONTENT,PSTATE,EUSER,EUSERNAME,CUSER,CUSERNAME,ETIME,CTIME");
    return dbQuery;
  }
  
  public ResumeintensionDaoInter getResumeintensionDaoImpl()
  {
    return this.resumeintensionDaoImpl;
  }
  
  public void setResumeintensionDaoImpl(ResumeintensionDaoInter dao) {
    this.resumeintensionDaoImpl = dao;
  }
  
  @Transactional
  public Resumeintension getResumeintensionEntityByUser(String userid)
  {
    return this.resumeintensionDaoImpl.getResumeintensionEntityByUser(userid);
  }
}
